//
//  RMMOrderCommonBottomView.m
//  Romomo
//
//  Created by puman on 2016/10/24.
//  Copyright © 2016年 mazegong. All rights reserved.
//

#import "RMMOrderCommonBottomView.h"

@implementation RMMOrderCommonBottomView
{
    UILabel *_label;
}
- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = kWhiteColor;
        
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.width, 1)];
        view.backgroundColor = COLORFROMCODE(0xEEEEEE, 1);
        [self addSubview:view];
        
        _leftButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _leftButton.frame = CGRectMake(15, 10.5, 74, 28);
        [_leftButton setTitleColor:kBasicColor forState:(UIControlStateNormal)];
        _leftButton.titleLabel.font = kBFont(14);
        _leftButton.layer.cornerRadius = 14;
        _leftButton.layer.masksToBounds = YES;
        [self addSubview:_leftButton];

        
        _but = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _but.frame = CGRectMake(kScreenWideth - 89, 10.5, 74, 28);
        [_but setTitleColor:kBasicColor forState:(UIControlStateNormal)];
        _but.titleLabel.font = kBFont(14);
        _but.layer.masksToBounds = YES;
        _but.layer.cornerRadius = 14;
        _but.layer.borderColor = kBasicColor.CGColor;
        _but.layer.borderWidth = 1;
        [self addSubview:_but];
        
        _middleBut = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _middleBut.frame = CGRectMake(_but.right - 100, 10.5, 904, 28);
        [_middleBut setTitleColor:kBasicColor forState:(UIControlStateNormal)];
        _middleBut.titleLabel.font = kBFont(14);
        _middleBut.layer.masksToBounds = YES;
        _middleBut.layer.cornerRadius = 14;
        _middleBut.hidden = YES;
        _middleBut.layer.borderColor = kBasicColor.CGColor;
        _middleBut.layer.borderWidth = 1;
        [self addSubview:_middleBut];

        _label = [[UILabel alloc] initWithFrame:CGRectMake(_but.left - 100, _but.top, 90, 28)];
        _label.font = kFont(14);
        _label.textColor = COLORFROMCODE(0xBFBFBF, 1);
        _label.hidden = YES;
        [self addSubview:_label];
    }
    return self;
}
- (void)setType:(NSString *)type{
    if ([type isEqualToString:@"去支付"]) {
        [_leftButton setTitle:@"取消订单" forState:(UIControlStateNormal)];
        [_but setTitle:@"去支付" forState:(UIControlStateNormal)];
        [_but setTitleColor:kWhiteColor forState:(UIControlStateNormal)];
        _but.backgroundColor = kBasicColor;
    } else if ([type isEqualToString:@"修改预约"]) {
        [_leftButton setTitle:@"申请退款" forState:(UIControlStateNormal)];
        [_but setTitle:@"修改预约" forState:(UIControlStateNormal)];
        _but.layer.borderWidth = 1;
        _but.layer.borderColor = kBasicColor.CGColor;
    } else if ([type isEqualToString:@"加单"]) {
        _leftButton.hidden = YES;
        [_but setTitle:@"加单" forState:(UIControlStateNormal)];
        _but.layer.borderWidth = 1;
        _but.layer.borderColor = kBasicColor.CGColor;

    } else if ([type isEqualToString:@"再来一单"]) {
        [_but setTitle:@"再来一单" forState:(UIControlStateNormal)];
        _but.layer.borderWidth = 1;
        _but.layer.borderColor = kBasicColor.CGColor;
        [_leftButton setTitle:@"评价获得颜值分" forState:(UIControlStateNormal)];
        _leftButton.frame = CGRectMake(_but.left - 150, 10.5, 140, 28);
        _leftButton.layer.cornerRadius = 14;
        _leftButton.layer.borderColor = kBasicColor.CGColor;
        _leftButton.layer.borderWidth = 1;
    }
}
- (void)setName:(NSString *)name{
    if ([name isEqualToString:@"订单已修改"]) {
        _label.hidden = NO;
    }
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
